import request from "@/utils/request.ts"
import type { PageModelResult } from '@/api/model/pageParam.ts';
import type { ResultModel } from '@/api/model/ResultModel.ts';
import type { commonStatus } from '@/api/model/CommonStatus.ts';
import type { adminModel } from '@/api/model/admin.ts';
import type { adminLogin, adminRegister } from '@/api/model/adminLogin.ts';


// 条件分页查询
export const queryAdminListApi = (username : string, realName : string, lastLoginTime : string, role : number, status : string, page : number, pageSize : number) =>
	request.get<any, PageModelResult>(`/admin?username=${username}&realName=${realName}&lastLoginTime=${lastLoginTime}&role=${role}&status=${status}&page=${page}&pageSize=${pageSize}`)


// 新增管理用户
export const addAdminApi = (admins : adminModel) => request.post<any, ResultModel>('/admin', admins)

// 编辑管理(步骤一：回显)
export const getByIdAdminApi = (id : number) => request.get<any, ResultModel>(`/admin/${id}`)


// 编辑管理(步骤二：更新管理信息)
export const updateAdminApi = (admins : adminModel) => request.put<any, ResultModel>('/admin', admins)


// 删除用户（批量删除）
export const deleteAdminApi = (ids : string) => request.delete<any, ResultModel>(`/admin?ids=${ids}`)

// 修改用户状态（批量）

export const disableAdminApi = (adminStatus : commonStatus) => request.put<any, ResultModel>('/admin/status', adminStatus)

// 登录
export const adminLoginApi = (loginadmin : adminLogin) => request.post<any, ResultModel>('/admin/login', loginadmin)

// 注册
export const adminRegisterApi = (registeradmin : adminRegister) => request.post<any, ResultModel>('/admin/register', registeradmin)